package com.mpgame;

import java.io.IOException;

import com.mpgame.common.constants.Constants;
import com.mpgame.common.network.GrpcServer;
import com.mpgame.common.utils.ConsulUtil;
import com.mpgame.common.utils.Log;
import com.mpgame.database.mysql.manager.MySqlMgr;
import com.mpgame.database.redis.manager.RedisMgr;
import com.mpgame.managers.SceneManager;
import com.mpgame.service.GameSvc;

public class GameServer 
{
    public static void main( String[] args ) throws IOException, InterruptedException
    {
        MySqlMgr.getInstance().initGame();
        RedisMgr.getInstance().init();
        if(MySqlMgr.getInstance().testConnection("game")) Log.warn("连接成功！");
        else Log.err("连接失败！");
        int port = Constants.CPorts.GAME_GRPC_PORT;
        SceneManager.getInstance();
        GrpcServer server = new GrpcServer(port).registService(new GameSvc());

        ConsulUtil.registerAgentService("game-service", port);

        server.start();
        server.blockUntilShutdown();
    }
}
